﻿using System;
using System.Linq;
using RobotGerchik.DataClass;
using System.Collections.ObjectModel;
using RobotGerchik.DataClass.Gerchik;

namespace RobotGerchik.Config
{
    class History
    {

        private Data _data;

        #region Загрузка

        public History(DataClass.Data _dataProvider)
        {
            this._data = _dataProvider;
        }

        public void Load()
        {
            _data.GechikRobotItemList = GetGerchikRobot();
        }

        private ObservableCollection<GechikRobotItem> GetGerchikRobot()
        {
            return (ObservableCollection<GechikRobotItem>)XMLHistory.GetXmlData(XMLHistory.FILENAME_GerchikRobots);
        }

        #endregion

        #region Сохранение

        public void Save()
        {
            SetGerchikRobot(_data.GechikRobotItemList);
        }

        private void SetGerchikRobot(ObservableCollection<GechikRobotItem> observableCollection)
        {
            XMLHistory.SetXmlData(XMLHistory.FILENAME_GerchikRobots, (Object)(observableCollection.ToList()));
        }

        #endregion
    }
}
